package com.clkj.sunhelp.mvp.publicityshow.publicityofapplyobj;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.clkj.sunhelp.R;
import com.clkj.sunhelp.adapter.vp.ViewPagerFragmentAdapterWithTab;
import com.clkj.sunhelp.common.Config;
import com.clkj.sunhelp.mvp.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;



/**申请对象公示界面
 * Created by Administrator on 2017/3/26.
 */

public class ActivityPublicityOfApplyObj extends BaseActivity{


    private TabLayout layoutTab;
    private ViewPager vp;

    List<Fragment> mTabFragmentList = new ArrayList<>();
    List<String> mTabTitleList = new ArrayList<>();


    ViewPagerFragmentAdapterWithTab mVpAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_publicity_apply_obj_show_view);
        initTitleWithRightTvOrIv(null,null,"申请对象公示",true,null,null);
        initData();
        assignView();
        initView();
    }

    @Override
    public void initData() {
        mTabTitleList.add("初次公示");
        mTabTitleList.add("二次公示");
    }

    @Override
    public void assignView() {


        layoutTab = (TabLayout) findViewById(R.id.layout_tab);
        vp = (ViewPager) findViewById(R.id.vp);

    }

    @Override
    public void initView() {
        mTabFragmentList.add(FragmentPublicityOfApplyObjList.getInstance(Config.TYPE_STR_FIRST_PUBLICITY_OF_APPLY_OBJ,Config.TYPE_FIRST_PUBLICITY_OF_APPLY_OBJ));
        mTabFragmentList.add(FragmentPublicityOfApplyObjList.getInstance(Config.TYPE_STR_SECOND_PUBLICITY_OF_APPLY_OBJ,Config.TYPE_SECOND_PUBLICITY_OF_APPLY_OBJ));

        mVpAdapter = new ViewPagerFragmentAdapterWithTab(getSupportFragmentManager(), mTabFragmentList, mTabTitleList, this);


        layoutTab.addTab(layoutTab.newTab().setText("初次公示"));
        layoutTab.addTab(layoutTab.newTab().setText("二次公示"));


        vp.setAdapter(mVpAdapter);
        vp.setCurrentItem(0);

        layoutTab.setupWithViewPager(vp);
        layoutTab.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                vp.setCurrentItem(tab.getPosition());
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }
}
